package net.ncraft.mc.easyframework.easygame;

import de.rapha149.signgui.SignGUI;
import net.ncraft.mc.easyframework.easygame.gamekits.board.DefaultEBoard;
import net.ncraft.mc.easyframework.easygame.gamekits.board.EBoard;
import net.ncraft.mc.easyframework.easygame.gamekits.inventorygui.DefaultInventoryGui;
import net.ncraft.mc.easyframework.easygame.gamekits.inventorygui.InventoryGui;
import net.ncraft.mc.easyframework.easygame.gamekits.signgui.SignConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;

public class GameKits {

    private static final Map<String, GamePlayer> GAME_PLAYERS = new HashMap<>();

    public static GamePlayer getGamePlayer(Player player) {
        if (player == null) return null;
        if (GAME_PLAYERS.containsKey(player.getUniqueId().toString())) {
            return GAME_PLAYERS.get(player.getUniqueId().toString());
        } else {
            GamePlayer gamePlayer = new GamePlayer(player);
            GAME_PLAYERS.put(player.getUniqueId().toString(), gamePlayer);
        }
        return GAME_PLAYERS.get(player.getUniqueId().toString());
    }

    public static EBoard createBoard(JavaPlugin plugin, String title) {
        return new DefaultEBoard(plugin, title);
    }

    public static SignGUI creatSignGui(SignConfiguration configuration) {
        return SignGUI.builder().setLine(0, configuration.getLine1())
                .setLine(1, configuration.getLine2())
                .setLine(2, configuration.getLine3())
                .setLine(3, configuration.getLine4())
                .setType(configuration.getType())
                .setColor(configuration.getColor())
                .setHandler(configuration.getHandler()).build();
    }

    public static InventoryGui createInventoryGui(int size, String title, JavaPlugin plugin) {
        return new DefaultInventoryGui(size, title, plugin);
    }

}
